home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17648 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.1 KB  |  55 lines

  1. Newsgroups: comp.lang.java,comp.lang.c++,comp.lang.smalltalk
  2. Path: news.hawaii.edu!phinely
  3. From: phinely@Hawaii.Edu (Peter Hinely)
  4. Subject: Re: Will Java kill C++? (definition of strong typing)
  5. X-Nntp-Posting-Host: uhunix4.its.hawaii.edu
  6. Message-ID: <Dpyro4.8o9@news.hawaii.edu>
  7. Sender: news@news.hawaii.edu
  8. Organization: University of Hawaii
  9. References: <31682FFE.2781E494@bbn.com> <dbell-1 <3171810F.2E2@funsys.se> <4l0f6o$sec@nkosi.well.com>
  10. Date: Tue, 16 Apr 1996 16:40:51 GMT
  11.  
  12. In article <4l0f6o$sec@nkosi.well.com>,  <sparker@well.com> wrote:
  13. >
  14. >The pertinent distinctions would seem to be:
  15. >
  16. >*How* typing takes place - the static/dynamic distinction.
  17. >*When* typing takes place - the early/late distinction.
  18. >*Breadth* of typing - how wide/narrow are the types handled
  19. >by the language? For example C and COBOL have only a handful
  20. >of types. Languages such as C++, ST, and Java, whose class
  21. >mechanism allows user-definition of types can permit finer
  22. >distinction of types. Eg in C a string can represent both an
  23. >address or a set of modem initialization instructions, and this
  24. >is the only way to implement them. In an OO language, different
  25. >classes can represent the two. I would judge the latter set of
  26. >languages to have a 'narrower' typing mechanism than the former.
  27. >>
  28.  
  29. Some languages have typing systems that don't fit in the conventional molds.
  30.  
  31. For example in Dylan:
  32.  
  33.   define variable *my-variable* = 0;
  34.  
  35. binds *my-variable* to the integer object 0.
  36.  
  37. The binding of *my-variable* can be later be changed to refer to an 
  38. object of any class (i.e. floating point numbers, strings, collections, even 
  39. classes and functions).
  40.  
  41. You can however specify type information for variables that you declare, 
  42. which limits their type:
  43.  
  44.   define variable *my-variable* :: <integer> = 0;
  45.  
  46. In this case, the binding of *my-variable* can be only be changed to refer 
  47. to another integer.
  48.  
  49.  
  50. This type system allows Dylan programs to be prototyped rapidly without
  51. type information.  Type information can later be added in, which the
  52. compiler can use to optimize the program better, giving you the best of 
  53. both worlds:  rapid development and good performance in your final program.
  54.  
  55.